package com.shycloud.mido.organ.ranking;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shycloud.mido.organ.api.vo.RankingVO;
import com.shycloud.mido.organ.mapper.MemberMapper;
import com.shycloud.mido.organ.mapper.WorksMapper;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

@Component("type0")
@AllArgsConstructor
public class RankingAll extends Ranking {

	/** 用户模块 mapper */
	private MemberMapper memberMapper;
	/** 作品模块 mapper */
	private WorksMapper worksMapper;

	@Override
	public IPage<RankingVO> getRankingList(String username, Page page) {

		IPage<RankingVO> finalResult;

		//所有用户
		if (StringUtils.isEmpty(username)) {
			finalResult = worksMapper.getRankingAllCountList(page);
		}

		//指定用户
		else {
			finalResult = getOneUserWorks(username, memberMapper, worksMapper, page);
		}
		return finalResult;

	}
}
